/***************************************************************************
 *            sales.h
 *
 *  Fri Jan  5 17:11:38 2007
 *  Copyright  2007  Min Seok Seo
 *  <msseo@oasyss.co.kr>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with main.c; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef LINUXPOS_SALES_H
#define LINUXPOS_SALES_H

#include <iostream>
#include <gtkmm.h>
#include <pqxx/connection>
#include <pqxx/transaction>
#include <pqxx/result>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include "usbcid.h"

using namespace PGSTD;
using namespace pqxx;
using namespace std;

class Sales 
{
public:
	
	Sales();
	virtual ~Sales();
	
	//Variables
	std::string strConn;		/* DB 설정 */
	
	Glib::ustring Ujname;		/* 업장명 */
	Glib::ustring User;			/* 사용자 ID */
	Glib::ustring Username;		/* 사용자 이름 */
	Glib::ustring Ver;			/* 프로그램 버젼 */
	Glib::ustring Workdate;		/* 영업일 */
	Glib::ustring Nowdate;		/* 현재 날짜 */
	Glib::ustring Time;			/* 현재 시간 */
	Glib::ustring Total_Person;	/* 방문객 */
	Glib::ustring Total_Price;	/* 수입액 */
	Glib::ustring SOSOK;		/* 업장 소속 */
	Glib::ustring Ujcd;			/* 업장 코드 */

	Glib::ustring SOSOKADDR;	/* 주소 */
	Glib::ustring SOSOKTNAME;	/* 대표자 */
	Glib::ustring SOSOKSANO;	/* 사업자등록번호 */
	Glib::ustring SOSOKTEL;		/* TEL */
	Glib::ustring SOSOKFAX;		/* FAX */

	std::string nowtablnum;		/* 현재 테이블 번호 */
	std::string nowACCT;		/* 이동 손님번호 */
	std::string transtablnum;	/* 현재 테이블 번호 */
	std::string transACCT;		/* 이동 손님번호 */
	std::string nowBILL;		/* 현재 빌번호 */
	std::string transBILL;		/* 이동 빌번호 */
	std::string maxACCT;		/* 손님번호 */
	std::string maxBILL;		/* 빌번호 */

	std::string card_name[40];  /* 카드 이름 */
	std::string detailstr[12];
	std::string CHKINCODE;		/* 체크인 코드 */
	std::string CHKOUTCODE;		/* 체크아웃 코드 */
	
	std::string CHKOUTPRICE;	/* 체크아웃 금액 */

	int vatbuff;
	int svcbuff;
	
	// 영업장 소속 유저 아이디 받아서 초기화
	void Init(std::string get_SOSOK, std::string get_USERID);
	// 업장 정보 받아오기
	void Ujinfo();
	// 방문객수 갱신 함수
	void Total_Person_Func();
	// 총 수입액 갱신 함수
	void Total_Price_Func();
	// 문자열 관련 함수
	void Timer();
	void Tokenize(const string& str, vector<string>& tokens, const string& delimiters = "&");
	std::string sep_thousands(int i);
protected:	
};

#endif // LINUXPOS_SALES_H

 
